package com.op.teachingliteapp.bean;

import org.json.JSONException;
import org.json.JSONObject;

import com.op.teachingliteapp.database.table.CourseNotifTable;
import com.op.teachingliteapp.database.table.CourseTable;

/**
 * Created by Genji on 2015/6/25. Modified by Kevin
 */
public class CourseBean extends BaseBean {
	
	private String name;
	private String credit;
	private String period;
	private String userId;
	private String iconUrl;
	private String deptId;

	public void setName(String name) {
		contentValues.put(CourseTable.COLUMN_NAME, name);
		this.name = name;
	}

	public void setCredit(String credit) {
		contentValues.put(CourseTable.COLUMN_CREDIT, credit);
		this.credit = credit;
	}

	public void setPeriod(String period) {
		contentValues.put(CourseTable.COLUMN_PERIOD, period);
		this.period = period;
	}

	public void setUserId(String userId) {
		contentValues.put(CourseTable.COLUMN_USER_ID, userId);
		this.userId = userId;
	}

	public String getName() {
		return name;
	}

	public String getCredit() {
		return credit;
	}

	public String getPeriod() {
		return period;
	}

	public String getUserId() {
		return userId;
	}

	public String getIconUrl() {
		return iconUrl;
	}

	public void setIconUrl(String iconUrl) {
		contentValues.put(CourseTable.COLUMN_ICON_URL, iconUrl);
		this.iconUrl = iconUrl;
	}

	public String getDeptId() {
		return deptId;
	}

	public void setDeptId(String deptId) {
		contentValues.put(CourseTable.COLUMN_DEPT_ID, deptId);
		this.deptId = deptId;
	}

	@Override
	public void fillAttributeByJson(JSONObject jsonObject) {
		setId(getJsonValue(jsonObject, CourseTable.TABLE_COURSE, CourseTable.COLUMN_ID));
		setCreateTime(getJsonValue(jsonObject, CourseTable.TABLE_COURSE, CourseTable.COLUMN_CREATE_TIME));
		setUpdateTime(getJsonValue(jsonObject, CourseTable.TABLE_COURSE, CourseTable.COLUMN_UPDATE_TIME));
		setName(getJsonValue(jsonObject, CourseTable.TABLE_COURSE, CourseTable.COLUMN_NAME));
		setCredit(getJsonValue(jsonObject, CourseTable.TABLE_COURSE, CourseTable.COLUMN_CREDIT));
		setPeriod(getJsonValue(jsonObject, CourseTable.TABLE_COURSE, CourseTable.COLUMN_PERIOD));
		setUserId(getJsonValue(jsonObject, "null", CourseTable.COLUMN_USER_ID));
		setIconUrl(getJsonValue(jsonObject, CourseTable.TABLE_COURSE, CourseTable.COLUMN_ICON_URL));
		setDeptId(getJsonValue(jsonObject, "null", CourseTable.COLUMN_DEPT_ID));
	}

}
